package vip.xiaonuo.client.modular.testPaper.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.client.modular.testPaper.entity.ClientTestPaper;
import vip.xiaonuo.client.modular.testPaper.param.ClientTestPaperIdParam;
import vip.xiaonuo.client.modular.testPaper.param.SubmitTestPaperParam;
import vip.xiaonuo.client.modular.testPaper.result.TestPaperResult;
import vip.xiaonuo.client.modular.testPaper.service.ClientTestPaperService;
import vip.xiaonuo.common.pojo.CommonResult;

@Tag(name = "试卷控制器")
@RestController
public class ClientTestPaperController {

    @Resource
    private ClientTestPaperService clientTestPaperService;

    /**
     * 创建模拟试卷
     */
    @Operation(summary = "创建模拟试卷")
    @PostMapping("client/testPaper/createSimulateTestPaper")
    public CommonResult<String> createSimulateTestPaper(ClientTestPaperIdParam clientTestPaperIdParam) {
        ClientTestPaper testPaper = clientTestPaperService.createSimulateTestPaper(clientTestPaperIdParam.getId());
        return CommonResult.data(testPaper.getId());
    }

    /**
     * 获取试卷
     */
    @Operation(summary = "获取试卷")
    @PostMapping("client/testPaper/getTestPaperInfo")
    public CommonResult<TestPaperResult> getTestPaperInfo(ClientTestPaperIdParam clientTestPaperIdParam) {
        TestPaperResult testPaperResult = clientTestPaperService.getTestPaperInfo(clientTestPaperIdParam);
        return CommonResult.data(testPaperResult);
    }


    //提交试卷
    @Operation(summary = "提交试卷")
    @PostMapping("client/testPaper/submitTestPaper")
    public CommonResult<ClientTestPaper> submitTestPaper(@RequestBody SubmitTestPaperParam submitTestPaperParam) {
        ClientTestPaper clientTestPaper = clientTestPaperService.submitTestPaper(submitTestPaperParam);
        return CommonResult.data(clientTestPaper);
    }

    /**
     * 获取试卷-带答案
     */
    @Operation(summary = "获取试卷-带答案")
    @PostMapping("client/testPaper/getTestPaperAnswerInfo")
    public CommonResult<TestPaperResult> getTestPaperAnswerInfo(ClientTestPaperIdParam clientTestPaperIdParam) {
        TestPaperResult testPaperResult = clientTestPaperService.getTestPaperAnswerInfo(clientTestPaperIdParam);
        return CommonResult.data(testPaperResult);
    }



}
